<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>
<script type="application/javascript" src="/js/plugins/ckeditor/ckeditor.js"></script>
    <script type="text/javascript">
        $(function(){

            $('#editForm').ajaxForm(function(data){
                if(data.success){
                    location.reload();
                }else{
                    $.messager.alert("温馨提示",data.msg);
                }
            });
      //初始化
            var ck = CKEDITOR.replace('editor1');
            $('.submitBtn').click(function(){
                var data = ck.getData();
                $('#editor1').html(data);
                $('#editForm').submit();
            });

            $("#pagination").twbsPagination({
                    totalPages:${result.pages} || 1,
                    startPage:${result.pageNum},
                    visiblePages:5,
                    first:"首页",
                    prev:"上一页",
                    next:"下一页",
                    last:"尾页",
                    onPageClick:function(event,page){
                        $("#currentPage").val(page);
                        $("#searchForm").submit();
                    }
                });

                $("#query").click(function(){
                    $("#currentPage").val();
                    $("#searchForm").submit();
                });

              /*  //模态框

            $(".showBtn").click(function(){
                $('#editForm input').val("");
                var obj=$(this).data("json");
                // console.log(obj);




                if(obj){
                    $('#editForm input[name="id"]').val(obj.id);
                    $('#editForm input[name="title"]').val(obj.title);
                    $('#editForm input[name="sequence"]').val(obj.sequence);
                    $('#editForm select[name="state"]').val(obj.state);
                    $('#editForm input[name="coverUrl"]').val(obj.coverUrl);
                    $('#coverUrl').attr('src',obj.coverUrl);
                    $('#skip').attr('href',"/release/list.do?travelId="+obj.travelId);
                    $('#strategies').val(obj.strategyId);

                    //查询所有的攻略类别
                    $.get('/strategyCatalog/allByStrategyId.do',{strategyId:obj.strategyId},function(data){
                         var temp="";
                         $.each(data,function(index,ele){
                           temp+='<option value="'+ele.id+'">'+ele.name+'</option>';
                         })
                        $('#SelectcatalogId').html(temp);
                        $('#SelectcatalogId').val(obj.catalogId);


                    });
                    $.get('/strategyDetail/getContentById.do',{id:obj.id},function(data){
                        ck.setData(data.content);
                    });


                }
                $('#showModal').modal('show')*/
            });

           /* //二级联动
           $('#strategies').change(function(){
                var staId= $(this).val();
                $.get('/strategyCatalog/allByStrategyId.do',{strategyId:staId},function(data) {
                    var temp = "";
                    $.each(data, function (index, ele) {
                        temp += '<option value="' + ele.id + '">' + ele.name + '</option>';
                    })
                    $('#SelectcatalogId').html(temp);

            });*/


            });


        });
    </script>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "strategyTravel" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>大家都再看</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/strategyDetail/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                    </div>
                    <div class="form-group">
                        <label>关键字</label>
                        <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!''}">
                    </div>
                    <div class="form-group">
                        <button id="query" type="button" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                    </div>
                    <div class="form-group">
                        <button  type="button" class="btn btn-success showBtn"><i class="icon-search "></i> 新增</button>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>发布时间</th>
                        <th>排序</th>
                        <th>攻略类别</th>
                        <th>状态</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
					<#list result.list as vo>
                    <tr>
                        <td>${vo_index+1}</td>
                        <td>${vo.title!""}</td>
                        <td><img src='${vo.coverUrl!""}' width="30px"/></td>
                        <td>${(vo.releaseTime?string("yyyy-MM-dd HH:mm:ss"))!""}</td>
                        <td>${vo.sequence}</td>
                        <td>${vo.catalog.name}</td>
                        <td>
                        <#if vo.state == 0>
                            草稿
                        <#elseif vo.state == 1>
                            发布
                        </#if>
                        </td>
                        <td>
                            <a href="javascript:" class="btn btn-info btn-xs showBtn" data-json='${vo.json}'>
                                <span class="glyphicon glyphicon-pencil"></span> 修改
                            </a>

                       </td>
                    </tr>
					</#list>
                    </tbody>
                </table>

                <div style="text-align: center;">
                    <ul id="pagination" class="pagination"></ul>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="showModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">游记修改</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal" action="/strategyDetail/saveOrUpdate.do" method="post" id="editForm" enctype="multipart/form-data">
                    <input type="hidden"  name="id">
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">标题：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="title" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">封面：</label>
                        <div class="col-lg-7">
                            <img id="coverUrl">
                            <input type="file" class="form-control"  name="file" >
                            <input type="hidden" class="form-control"  name="coverUrl" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">所属攻略：</label>
                        <div class="col-lg-7">
                            <select class="c-select form-control" name="strategyId" id="strategies" >
                                <option value="-1">全部</option>
                                <#list stragegies as s>
                                    <option value="${s.id}">${s.title}</option>
                                </#list>
                            </select>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">攻略类别：</label>
                        <div class="col-lg-7">
                            <select  name="catalog.id" id="SelectcatalogId" class="form-control form-control-chosen" >

                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">是否发布：</label>
                        <div class="col-lg-7">
                            <select class="c-select form-control" name="state" >
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">排序：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="sequence" >
                        </div>
                    </div>
                     <textarea name="strategyContent.content" id="editor1"></textarea>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>

</div>
<style>
    #showModal img{
        width:100%
    }
    #showModal  .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }

</style>
</body>
</html>